//
//  LongerRentalBillCountCell.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/6/29.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "LongerRentalBillCountCell.h"

@interface LongerRentalBillCountCell ()

@property (nonatomic,strong) UILabel *titleLbl;

@property (nonatomic,strong) UILabel *tipLbl;

@end

@implementation LongerRentalBillCountCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLbl];
        [self.contentView addSubview:self.tipLbl];
        [self.contentView addSubview:self.inputTextField];
        [self.tipLbl sizeToFit];

        [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.width.mas_equalTo(30);

        }];
        
        [self.tipLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).mas_offset(-kMarginOffsetX);
            make.width.mas_equalTo(20);

            make.centerY.mas_equalTo(self.contentView.mas_centerY);
        }];
        
        [self.inputTextField mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.titleLbl.mas_right).offset(70);
            make.right.mas_equalTo(self.tipLbl.mas_left).mas_offset(-kRegisterMarginOffsetX);
            make.centerY.mas_equalTo(self.contentView);

           }];
        

        
    }
    return self;
}

- (void)setPlaceholder:(NSString *)placeholder{
    self.inputTextField.placeholder = placeholder;
    [UIConfigure configureUITextField:self.inputTextField fontSize:15 color:kGrayTextColor];
}

- (void)textFieldDidChange:(UITextField *)textField{
    if (self.inputMaxLength>0) {
        if (textField.text.length > self.inputMaxLength) {
            textField.text = [textField.text substringToIndex:self.inputMaxLength];
        }
    }
    if (self.textChangeBlock) {
        self.textChangeBlock(self.tag,textField.text);
    }
}



- (UITextField *)inputTextField{
    if (!_inputTextField) {
        _inputTextField = [[UITextField alloc]init];
        [_inputTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        [_inputTextField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
        _inputTextField.font = PingFangZhongChangGuiForFont(16);
     }
    return _inputTextField;
}


MACRO_UILabel_LazyloadWithPFCGFont(titleLbl, @"计费", kBlackColor, 15)
MACRO_UILabel_LazyloadWithPFCGFont(tipLbl, @"元", kBlackColor, 15)

@end
